package com.qc.bug.Controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import com.qc.bug.Util.SendMsgUtil;
import com.qc.bug.Util.msgUtil;
import com.qc.bug.Util.randomNumber;

@Controller

@RequestMapping(value="sendMsgContr")
public class sendMsgController {

	@ResponseBody
	@RequestMapping(value="sendmsg")
	public String senMsg(@RequestParam String phone,@RequestParam int type,HttpSession session){
		
		String number=randomNumber.getNumber();
		System.out.println(number);
		String msg=null;
		if(type==1){
			msg=msgUtil.updateMsg(number);
		}else if(type==2){
			msg=msgUtil.rigedistrMsg(number);
		}
		int a=SendMsgUtil.sendMsg(msg, phone);
		
		session.setAttribute("checkMsg", number);
		
		
		return a+"";
		
	}
	
	
}
